package Iterator;

import java.util.ArrayList;
import java.util.List;

public class TCLTelevision implements Television{
    //private Object[] obj = {"CCTV-1","CCTV-2","CCTV-3","CCTV-4","CCTV-5"};

    private List<String> obj;

    public TCLTelevision()
    {
        obj = new ArrayList<String>();
        obj.add("CCTV-1");
        obj.add("CCTV-2");
        obj.add("CCTV-3");
        obj.add("CCTV-4");
    }


    @Override
    public TVIterator createIterator() {
        return new TCLIterator();
    }


    private class TCLIterator implements TVIterator
    {
        private int currentIndex = 0;

        @Override
        public void setChannel(int i) {
            currentIndex = i;
        }

        @Override
        public void next() {
            if(currentIndex < obj.size())
            {
                currentIndex++;
            }
        }

        @Override
        public void previous() {
            if(currentIndex > 0)
            {
                currentIndex--;
            }
        }

        @Override
        public Object currentChannel() {
            return obj.get(currentIndex);
        }

        @Override
        public boolean isFirst() {
            return currentIndex == 0;
        }

        @Override
        public boolean isLast() {
            return currentIndex == obj.size();
        }


    }
}
